# -*- coding: utf-8 -*-

#    Copyright (C) 2014 by Promotux
#                       di Francesco Meloni snc - http://www.promotux.it/

#    Author: Francesco Meloni  <francesco@promotux.it>

#    This file is part of OdCollect.

#    OdCollect is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 2 of the License, or
#    (at your option) any later version.

#    OdCollect is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with OdCollect.  If not, see <http://www.gnu.org/licenses/>.



from web_lib.page import Page
from web_lib.webutils import Response, expose
#from dao.Ente import Ente
from web_lib.webutils import leggiInSessione

@expose('/italiaCives')
def italiaCives(req, subdomain=None):
    """
    """
    from dao.Main_News import MainNews
    if not leggiInSessione(sezione="Main", chiave="schema"):
        pageData = {'file' : "ic/index",
            "newss": MainNews().select(),
        }
        return Page(req).render(pageData)
    else:
        url_red = "/italiaCives/dashboard"
        return Page(req).redirect(url_red)

@expose('/italiaCives/cambiacomune')
def cambiacomune_ic(req, subdomain=None):
    """
    """
    if not leggiInSessione(sezione="Main", chiave="schema"):
        pageData = {'file' : "ic/index"}
        return Page(req).render(pageData)
    else:
        pageData = {'file' : "ic/modal_cambio_ente"}
        return Page(req).render(pageData)
